package com.douwong.student.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.douwong.student.R;
import com.douwong.student.model.TeacherOnline;

import java.util.List;

/**
 * @autor yichao
 * @time 2017/3/319:44
 * @des ${TODO}
 */
public class ScanIpAdapter extends BaseAdapter {


    private final Activity mActivity;
    private final List<TeacherOnline> mTeacherOnlineList;

    public ScanIpAdapter(Activity activity, List<TeacherOnline> teacherOnlineList) {

        mActivity = activity;
        mTeacherOnlineList = teacherOnlineList;
    }

    @Override
    public int getCount() {
        return mTeacherOnlineList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(mActivity).inflate(
                    R.layout.scan_ip_item, null);
            holder = new Holder();
            holder.shcool_type= (TextView) convertView.findViewById(R.id.school_type);
            holder.school_text= (TextView) convertView.findViewById(R.id.school_text);
            holder.class_text = (TextView) convertView.findViewById(R.id.class_text);
            holder.teacher_text= (TextView) convertView.findViewById(R.id.teacher_text);
            convertView.setTag(holder);
        } else {
            holder = (Holder) convertView.getTag();
        }
    if (mTeacherOnlineList.get(position).isLocal()){
    holder.shcool_type.setText("本地学校");
    }else {
    holder.shcool_type.setText("远程学校学校");
}
        holder.school_text.setText(mTeacherOnlineList.get(position).getSchoolRemark()+mTeacherOnlineList.get(position).gradeRemark+mTeacherOnlineList.get(position).getClassRemark()+"");
        holder.class_text.setText(mTeacherOnlineList.get(position).getTeacherInfo().getTeacherRemark()+"");
       // holder.teacher_text.setText();
        return convertView;
    }

    class Holder {
        TextView shcool_type;
        TextView class_text;
        TextView school_text;
        TextView teacher_text;


    }
}
